package ca.etsmtl.log730.projet2.view.data;

import java.util.ArrayList;
import java.util.UUID;

import javax.swing.table.AbstractTableModel;

import ca.etsmtl.log730.projet2.connectors.clientserver.nodes.DocumentMap;
import ca.etsmtl.log730.projet2.documents.Document;

public class DocumentTableModel extends AbstractTableModel {

	private DocumentMap DocumentMap = new DocumentMap ();
	/**
	 * 
	 */
	private static final long serialVersionUID = 1276521213342936963L;

	@Override
	public int getColumnCount() {
		return 4;
	}

	@Override
	public int getRowCount() {
		return DocumentMap.size();
	}

	@Override
	public Object getValueAt(int y, int x) {
		ArrayList<UUID> ll = new ArrayList<UUID>(DocumentMap.keySet());
		if(x == 0) return ll.get(y);
		Document d = DocumentMap.get(ll.get(y));
		if(x == 1) return d.getName();
		else if(x == 2) return DocumentMap.getEditorQueue(ll.get(y));
		else if(x == 3) return DocumentMap.getViewers(ll.get(y));
		return "";
		
	}
	
	public String getColumnName(int n) {
		if(n == 0) return "ID";
		else if(n == 1) return "NAME";
		else if(n == 2) return "EDITOR";
		else if(n == 3) return "VIEWERS";
		return "";
	}

	public DocumentMap getDocumentMap() {
		return DocumentMap;
	}

	public void setDocumentMap(DocumentMap DocumentMap) {
		this.DocumentMap = DocumentMap;
	}

}
